package org.yejiali.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.yejiali.common.constants.SystemConstants;
import org.yejiali.common.response.ResponseResult;
import org.yejiali.domain.entity.Comment;
import org.yejiali.service.CommentService;
import org.springframework.web.bind.annotation.*;
/**
 * 评论表(Comment)表控制层
 *
 * @author yejiali
 * @since 2025-02-20 20:28:57
 */
@RestController
@RequestMapping("/comment")
@Api(tags = "评论")
public class CommentController  {

    /**
     * 服务对象
     */
    @Autowired
    private CommentService commentService;

    /**
     * 查看评论
     * @param articleId
     * @param pageNum
     * @param pageSize
     * @return
     */


    @GetMapping("/commentList")
    public ResponseResult commentList(@RequestParam(name = "articleId") Long articleId,
                                      @RequestParam(name ="pageNum") Integer pageNum,
                                      @RequestParam(name = "pageSize") Integer pageSize){
        return commentService.commentList(SystemConstants.ARTICLE_COMMENT,articleId,pageNum,pageSize);
    }
    /**
     * 发表评论
     */
    @PostMapping()
    public ResponseResult addComment(@RequestBody Comment comment){
        return commentService.addComment(comment);
    }

    /**
     * 友链评论列表
     */
    @ApiOperation(value = "友链评论列表",notes = "获取一页友链评论")
    @GetMapping("/linkCommentList")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页号"),
            @ApiImplicitParam(name = "pageSize", value = "每页大小")
    })
    public ResponseResult linkCommentList(@RequestParam Integer pageNum,@RequestParam Integer pageSize){
        return commentService.commentList(SystemConstants.LINK_COMMENT,null,pageNum,pageSize);
    }


}

